package ioexercise;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class ReadStringDemo {
    public static void main(String[] args) throws IOException {
        // 读文本数据
        FileInputStream fis=new FileInputStream("1.txt");
        File file=new File("1.txt");
        byte[] data=new byte[(int)file.length()];
        fis.read(data);//一次性读取数据到data中
        String line=new String(data, StandardCharsets.UTF_8);
        System.out.println(line);
        fis.close();
    }
}
